package com.cloud.code.牛客网;

import java.util.*;

public class Test28 {

    static class User implements Comparable {
        int tall;
        int xiangDui;

        User(int tall, int xiangDui) {
            this.tall = tall;
            this.xiangDui = xiangDui;
        }

        @Override
        public int compareTo(Object o) {
            User user = (User) o;
            if (this.xiangDui == user.xiangDui) {
                return this.tall - user.tall;
            } else {
                return this.xiangDui - user.xiangDui;
            }
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {

            int H = scanner.nextInt();
            int n = scanner.nextInt();
            int[] group = new int[n];
            for (int i = 0; i < group.length; i++) {
                group[i] = scanner.nextInt();
            }

            Set<User> set = new TreeSet<>();
            for (int i = 0; i < group.length; i++) {
                User user = new User(group[i], H - group[i] > 0 ? H - group[i] : group[i] - H);
                set.add(user);
            }

            set.forEach(tem -> {
                System.out.println(tem.tall + " ");
            });

        }
    }
}
